
		var flowNodeArr;
		var execState;
		
		function flowNodeFormatter(value){
			for(var i=0; i<flowNodeArr.length; i++){
				if (flowNodeArr[i].ID == value) return flowNodeArr[i].NAME;
			}
			return value;
		}
		
		function stateFormatter(value){
			if(value=='')return '未执行';
			for(var i=0; i<execState.length; i++){
				if (execState[i].ID == value) return execState[i].NAME;
			}
			return value;
		}
		
		//加载下拉框
		function loadSelect(){
			alert("OK");
		}
		
		var divName="";
		
		//00000000000000000 界面效果  插入环节和父环节
		function confirmation(){
			$('#InsertLink').dialog('close');
			if(parentFlowId == 1){//为1 则默认取节点
				var selRows = $('#LINKDATALIST').datagrid('getSelections');
				for(var i = 0; i < selRows.length; i++){
					$('#PLANDATALIST').datagrid('appendRow',{
						END_DATE:'',
						EXECSTATE:'',
						BEGIN_DATE:'',
						DUTY_BUMEN:'',
						DUTY_MAN:'',
						FLOW_ID:selRows[i].FLOW_ID,
						PARENT_FLOW_ID:'',
						SORT_NUMBER:''
					});
				}
			}else if(parentFlowId == 2){//为2 则添加父节点
				var selParRow = $('#LINKDATALIST').datagrid('getSelected');
				var selRow = $('#PLANDATALIST').datagrid('getSelected');
				if(selRow == null){$.message.alert('提示','请选择一条环节点记录');return;};
				selRow.PARENT_FLOW_ID = selParRow.FLOW_ID+"";
				$('#PLANDATALIST').datagrid('refreshRow', dbRowIndex);
			}
		}
		//0000000000000  保存环节
		function savePlan(){
			var rows = $('#PLANDATALIST').datagrid('getRows');
			var flowNodes = new Array();
							for(var i = 0; i < rows.length; i++){
								flowNodes[i] = {
								'manageId':rows[i].MANAGE_ID,
								'xtId':xtid,
								'flowId':rows[i].FLOW_ID,
								'parentFlowId':rows[i].PARENT_FLOW_ID,
								'sortNumber':rows[i].SORT_NUMBER,
								'execstate':rows[i].EXECSTATE,
								'inputMan':rows[i].INPUT_MAN,
								'inputDate':rows[i].INPUT_DATE,
								'dutyMan':rows[i].DUTY_MAN,
								'dutyBumen':rows[i].DUTY_BUMEN,
								'beginDate':rows[i].BEGIN_DATE,
								'endDate':rows[i].END_DATE,
								'lastModDate':rows[i].LAST_MOD_DATE,
								'djId':rows[i].DJ_ID,
								'memo':rows[i].MEMO};
							}			
							var flowNodesList = {};
							flowNodesList = flowNodes;
							$.ajax({
				 				url:'../../node/saveFlowNodes',
				 				type:'post',
                  				contentType: "application/json;charset=utf-8",
				 				data:JSON.stringify(flowNodesList),
				 				dataType: "json",
				 				success:function(data){
				 					if(data.msg == 'success'){
				 						$.messager.alert('提示框','保存成功','info');
				 					}else{
				 						$.messager.alert('错误提示框',data.msg,'error');
				 					}
				 					$('#PLANDATALIST').datagrid('reload');
				 				}
				 			});
		}
		
		//------------------------------------------------------------------------------------------------------------------------------
		var a = document.documentElement.clientHeight - 110;
		var b = document.documentElement.clientWidth - 20;
		//选题ID
		var xtid;
		//基础按钮ID
		var butnId = 'XTButton';
		//DS ID
		var datastoreId = 'bj_xt';
		//窗口命名
		var winName = "选题立项";
		//字段缓存
		var clons = {};
		//对照信息
		//xtType 选题类型     author 作者  station 站点 oparator 用户
		//本页的选题立项数据
		var xtdata = new Array();
		//选中的暂存对象
		var rowObj = {};
		
		$(function(){
			xtid = '';
			a = document.documentElement.clientHeight - 110;
		 	b = document.documentElement.clientWidth - 20;
			$('#parentTabPanel').window('setTitle',"编辑选题");
			//加载按钮
			loadButns();
			//初始化datagrid
			loadDategrid();
			//加载字段
			loadClns();
			//加载对照信息
			loadDzSource();
			//初始化编辑选题计划的窗口
			loadDialog();
		});
		
		//加载节点的对照信息
		function loadDzSource(){
			$.ajax({
				url:'../../dz/queryDzList',
				type:'post',
				data:{dzIds:'xt_type;dz_operators;bs_station'},
				success:function(data){
					//xtType 选题类型     author 作者  station 站点 oparator 用户
					xtType = data[0];
					author = data[1];
					station = data[2];
					oparator = data[1];
				}
			});
		}
		
		
		function xtformatter(value){
			for(var i=0; i<xtType.length; i++){
				if (xtType[i].ID == value) return xtType[i].NAME;
			}
			return value;
		}
		
		function authformatter(value){
			var tmpName = '';
			if(value == null || value == '')return;
			var valueArr = value.split(";");
			for(var i = 0; i < valueArr.length; i++){
				for(var j=0; j<author.length; j++){
					if (author[j].ID == valueArr[i]) tmpName += author[j].NAME+";";
				}
			}
			return tmpName;
		}
		
		function stformatter(value){
			for(var i=0; i<station.length; i++){
				if (station[i].ID == value) return station[i].NAME;
			}
			return value;
		}
		function opformatter(value){
			for(var i=0; i<oparator.length; i++){
				if (oparator[i].ID == value) return oparator[i].NAME;
			}
			return value;
		}
		
//**V2.0.0******//加载选题字段*********************************************
		function loadClns(){
			$.ajax({
					type:'post',
					url:'../../framework/loadColumnsU',
					data:{'colId':'bj_xt','type':"3"},
					success:function(data){
						if(data ==""){
							alert("数据为空");
						}else{
							//请求一个组织列的方法
							clons = data;
							divName='QUERYCLN';//查询界面条件
							producePage(clons,divName,'3','')
						}
					}
			});
		}
		
		// 加载按钮
		function loadButns(){
			$.ajax({
				type:'post',
				url:'../../framework/buttonsList',
				data:{'butnId':butnId},
				success:function(data){
					if(data == ""){
						alert("按钮数据为空");
					}else{
						var buttons = data;
						var butHTML = "";
						for(var i = 0; i < buttons.length; i++){
							butHTML += formatButtons(buttons[i]);
						}
						$('#BUTTONS').html(butHTML);
						$('#QUERYBUT').html(butHTML);
						$.parser.parse();  //重新编译界面
					}
				}
			});
		}
		
/**V2.0.0加载数据表格**************************************/
		// 加载数据表格
		function loadDategrid(){
			$.ajax({
				type:'post',
				url:'../../framework/loadColumnsU',
				data:{'colId':'bj_xt','type':"4"},
				success:function(data){
					if(data ==""){
						alert("数据为空");
					}else{
						//请求一个组织列的方法
						producePage(data,'DATALISTA','4','');
						$('#DATALISTA').datagrid({
							onDblClickRow:function(rowIndex,rowData){
								showInfoWin(rowData.XT_ID);
							}
						});
					}
				}
 			});
		}
		
		//查询选题
		function queryXT(){
			var configStr = parseConfig('QUERYCLN');
			$('#queryConfig').html(parseConfigStr('QUERYCLN'));
			$('#xtTabPanel').tabs('select','选题列表');
			//加载shuju
			//$('#DATALIST').datagrid({url:'../../framework/loadData?dsId='+datastoreId+"&config="+configStr});
			
			
			$.ajax({
				url:'../../framework/loadData',
				data:{dsId:datastoreId,config:configStr},
				success:function(queryJson){
					$('#DATALIST').datagrid("loadData", queryJson);
					xtdata = queryJson.rows;
					$('#DATALIST').datagrid({url:queryJson.url});
				}
			});
			
		}
		
		//添加选题
 		function showAddWin(){
 			if(addYWTab('xtTabPanel',"添加选题","<div style='padding:20px;'><div id='ADDPAGEBUT'></div><form id='addXTForm'><table id='addXTWin'></table></form></div>")!=1){
	 			divName='addXTWin';//条件字段
				
//	 			makeColumns(clons,divName);
//*****V2.0.0*****************//ajax 加载录入框
	 			$.ajax({
					type:'post',
					url:'../../framework/loadColumnsU',
					data:{'colId':'bj_xt','type':"1"},
					success:function(data){
						console.log(data);
						if(data ==""){
							alert("数据为空");
						}else{
							//请求一个组织列的方法
							producePage(data,divName,'1','')
						}
					}
	 			});
	 			$.ajax({
					type:'post',
					url:'../../framework/buttonsList',
					data:{'butnId':'XTaddSave'},
					success:function(data){
						if(data == ""){
							alert("按钮数据为空");
						}else{
							var buttons = data;
							var butHTML = "";
							for(var i = 0; i < buttons.length; i++){
								butHTML += formatButtons(buttons[i]);
							}
							$('#ADDPAGEBUT').html(butHTML);
							$.parser.parse('#ADDPAGEBUT');  //重新编译界面
						}
					}
				});
 			}
 			//初始化添加窗口
 		} 
 		
 		//保存选题
		function saveXT(){
			if(checkRequire('addXTForm')=='Success'){
				var bjTopics = getFormJson('addXTForm');
				$.ajax({
					type:'post',
					url:'../../bjTopic/saveTopic',
					type:'post',
					contentType: "application/json;charset=utf-8",
					data:JSON.stringify(bjTopics),
					dataType: "json",
					success:function(data){
						if(data.msg == "success"){
							$('#addXTForm input[name=xtId]').val(data.info);
							$.messager.alert("提示","保存成功");
							//更新按钮
							$.ajax({
								type:'post',
								url:'../../framework/buttonsListC',
								data:{'butnId':'XTaddSave;XTsaveA'},
								success:function(data){
									if(data == ""){
										alert("按钮数据为空");
									}else{
										var buttons = data;
										var butHTML = "";
										for(var i = 0; i < buttons.length; i++){
											butHTML += formatButtons(buttons[i]);
										}
										$('#ADDPAGEBUT').html(butHTML);
										$.parser.parse('#ADDPAGEBUT');  //重新编译按钮
									}
								}
							});
						}else if(data.msg == "upsuccess"){
							$.messager.alert("提示","更新成功");
						}else if(data.msg == "fail"){
						 	$.messager.alert("提示","保存失败！","info");
						}else{
							$.messager.alert("提示",data.msg,"error");
						}
					}
				});
			} 
		}
		// 显示选题详情界面  1.加载字段 2.填充记录   3.将字段变灰
		function showInfoWin(rowId){
			xtid = rowId;
			var contentHTML = "<div style='padding:20px;'><div id='INFOPAGEBUT'></div><form id='upXTForm'><table id='upXTWin'></table></form></div>";
			divName='upXTWin';//条件字段
			var tmpC = 0;
			var okj = {};
						for(var i = 0; (i < xtdata.length) && (tmpC ==0); i ++){
							if( xtdata[i].XT_ID == xtid){
								okj = xtdata[i];
								rowObj = xtdata[i];
								tmpC = 1;
							}
						}
						
			if(addYWTab('xtTabPanel',"选题详情",contentHTML)!=1){
				//加载字段\按钮
				$.ajax({
					type:'post',
					url:'../../framework/loadColumnsU',
					data:{'colId':'bj_xt','type':"2"},
					success:function(data){
						if(data ==""){
							alert("数据为空");
						}else{
							//请求一个组织列的方法
							producePage(data,divName,'2','');
							//动态加载对照值   动态填充   全部变灰 //为确保动态对照加载完毕，所以ajax请求不可用封装的方法
							var dzIdstr = serializeEDIType(divName);
							$.ajax({
								url:'../../dz/queryDzList',
								type:'post',
								data:{dzIds:dzIdstr},
								success:function(data){
										//下拉框
										fillSelect(divName,data);
										fillInfo(divName,okj);
										//将字段变灰
										readOnlyAll(divName);
								}
							});
						}
					}
	 			});
				
				//加载多种按钮
				$.ajax({
					type:'post',
					url:'../../framework/buttonsListC',
					data:{'butnId':'XTInfo;XTsaveS'},
					success:function(data){
						if(data == ""){
							alert("按钮数据为空");
						}else{
							var buttons = data;
							var butHTML = "";
							for(var i = 0; i < buttons.length; i++){
								butHTML += formatButtons(buttons[i]);
							}
							$('#INFOPAGEBUT').html(butHTML);
							$.parser.parse('#INFOPAGEBUT');  //重新编译按钮
						}
					}
				});
				//加载对照信息
			}else{
				fillInfo(divName,okj);
				//将字段变灰
				readOnlyAll(divName);
			}
		}
		
		//显示更新界面   1.加载字段  2.填充
		function showUpTab(){
			divName='upTopicTb';//条件字段
			if(addYWTab('xtTabPanel',"修改选题","<div style='padding:20px;'><div id='UPTOPICBUT'></div><form id='upTopicForm'><table id='upTopicTb'></table></form></div>")!=1){
				//加载字段\按钮
//				makeColumns(clons,divName);
				$.ajax({
                    type:'post',
                    url:'../../framework/loadColumnsU',
                    data:{'colId':'bj_xt','type':'1'},
                    success:function(data){
                        if(data ==""){
                            alert("数据为空");
                        }else{
                            //请求一个组织列的方法
                            producePage(data,divName,'1','');
                            //加载对照信息
							var dzIdstr = serializeEDIType("upTopicTb");
							$.ajax({
								url:'../../dz/queryDzList',
								type:'post',
								data:{dzIds:dzIdstr},
								success:function(data){
										//下拉框
										fillSelect(divName,data);
										fillInfo(divName,rowObj);
										//将部分字段变灰
										readOnlyPart(divName);
								}
							});
                        }
                    }
                });
				$.ajax({
					type:'post',
					url:'../../framework/buttonsListC',
					data:{'butnId':'XTupSave;XTsaveS'}, //XTupSave;XTsaveS 
					success:function(data){
						if(data == ""){
							alert("按钮数据为空");
						}else{
							var buttons = data;
							var butHTML = "";
							for(var i = 0; i < buttons.length; i++){
								butHTML += formatButtons(buttons[i]);
							}
							$('#UPTOPICBUT').html(butHTML);
							$.parser.parse('#UPTOPICBUT');  //重新编译界面
						}
					}
				});
				
			}else{
				//填充记录
				fillInfo(divName,rowObj);
				readOnlyPart(divName);
			}
		}
		
		//更新选题   只在详情页面有
		function updateXT(){
			if(checkRequire('upTopicForm')=='Success'){
				var bjTopics = getFormJson('upTopicForm');
				$.ajax({
					type:'post',
					url:'../../bjTopic/saveTopic',
					type:'post',
					contentType: "application/json;charset=utf-8",
					data:JSON.stringify(bjTopics),
					dataType: "json",
					success:function(data){
						if(data.msg == "success"){
							$('#upTopicForm input[name=xtId]').val(data.info);
							$.messager.alert("提示","保存成功");
						}else if(data.msg == "upsuccess"){
							$.messager.alert("提示","更新成功");
						}else if(data.msg == "fail"){
						 	$.messager.alert("提示","保存失败！","info");
						}else{
							$.messager.alert("提示",data.msg,"error");
						}
					},
					error:function(data,msg,obj){$.messager.alert("提示",obj,"error");}
				});
			}
		}
		
		function showQuery(){
			$('#xtTabPanel').tabs('select',"条件查询");
			$('#queryCB').removeAttr('checked');
		}
		
		function loadDialog(){
			$("#costDialog").window({
				width:850,
				height:550,
				maximized:true,
				collapsible: true,
				maximizable: true,
				title:'编辑选题计划',
				left:150,
				top:10
			});
			$("#costDialog").window('close');
			//添加默认按钮
			loadXTPlanButn();
			//加载对照信息
			loadXTDzSource();
			//初始化字段
			loadXTPlanDategrid();
			//初始化节点框
			initInsertLink();
		}
		//编辑选题计划
 		function showPlan(){
 			var selXTid = $('#upXTForm input[name=xtId]').val();
 			if(selXTid ==  null || selXTid == '') return;
 			$("#costDialog").window('open');
 			$("#hideXTId").val(selXTid);
 			var configStr = "XT_ID-"+selXTid;
			$.ajax({
				url:'../../framework/loadData?page=1&rows=1000',
				data:{dsId:"XTPlan",config:configStr},
				success:function(queryJson){
					$('#PLAN_DATALIST').datagrid("loadData", queryJson);
					//$('#PLAN_DATALIST').datagrid({url:queryJson.url});
				}
			});
 		} 
 		//添加后的选题计划的按钮
 		function addShowPlan(){
 			var selXTid = $('#addXTForm input[name=xtId]').val();
 			if(selXTid ==  null || selXTid == '') return;
 			$("#costDialog").window('open');
 			$("#hideXTId").val(selXTid);
 			var configStr = "XT_ID-"+selXTid;
			$.ajax({
				url:'../../framework/loadData?page=1&rows=1000',
				data:{dsId:"XTPlan",config:configStr},
				success:function(queryJson){
					$('#PLAN_DATALIST').datagrid("loadData", queryJson);
					//$('#PLAN_DATALIST').datagrid({url:queryJson.url});
				}
			});
 		}
 		